function getId(id)
{
	try{
		return document.getElementById(id);
	}catch(e){}
	return false;
}
function showmore(ie,id,textclose,text)
{
    if(ie.innerHTML!=textclose)
    {
        getId(id).className='';
        ie.innerHTML=textclose;
    }else
    {
        getId(id).className='divmore';
        ie.innerHTML=text;
    }
}
function isEmail(s)
{
    var regm=/([a-zA-Z0-9|-|_]+)(@)([a-zA-Z0-9|-|_]+)(.)([a-zA-Z]+)/gi;
    var r=s.match(regm);
    if(r==null)return false;
    return true;
}

function openpopup(url,w,h)
{
    opener = window.open(url,"gl",'scrollbars=yes,menubar=no,status=yes,resizeble=yes,width='+w+',height='+h);
}
function getSizePage ()
{
    var mysize=new Object;
    if(window.innerHeight) {
        // all except explorer
        mysize.w = window.innerWidth;
        mysize.h = window.innerHeight;
    } else if(window.document.documentElement && window.document.documentElement.clientHeight) {
        // explorer 6 strict mode
        mysize.w = window.document.documentElement.clientWidth;
        mysize.h = window.document.documentElement.clientHeight;
    } else if(document.body) {
        // other explorers
        mysize.w = window.document.body.clientWidth;
        mysize.h = window.document.body.clientHeight;
    };
    return mysize;
};
function getPageSizeWithScroll()
{
    var mysize=new Object;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		mysize.h = window.innerHeight + window.scrollMaxY;
		mysize.w = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		mysize.h = document.body.scrollHeight;
		mysize.w = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		mysize.h = document.body.offsetHeight;
		mysize.w = document.body.offsetWidth;
  	}
	return mysize;
};
function addClass (n,c)
{
    removeClass(n,c);
    n.className = n.className ? n.className +' '+ c : c; 
}
function removeClass(n,c)
{
    c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
	return n.className = c != ' ' ? c : '';
}

function Trcheckbox(idroot)
{
    this.cboxs  = new Array;
    this.listid = '';
    this.html   = '';
    this.idroot = document.getElementById(idroot);
    this.colnow = null;
    this.add    = function(arg)
    {
        var _root = this;
        var count = this.cboxs.length;
        if(arg.g==0)
        {
            this.colnow           = document.createElement('span');
            this.colnow.className = 'col';
            this.cboxs[count]     =document.createElement('span');            
            this.cboxs[count].className='tcb p';
            this.cboxs[count].innerHTML=arg.name;
            this.cboxs[count].id=arg.id;
            this.cboxs[count].g   = true;
            this.cboxs[count].onclick=function()
            {
                _root.onchange(this);   
            };
            this.colnow.appendChild(this.cboxs[count]); 
            this.cboxs[count].childs=new Array();
            this.idroot.appendChild(this.colnow);
        }else
        {
            var chil        = document.createElement('span');
            chil.className  = 'tcb';
            chil.innerHTML  = arg.name;
            chil.id         = arg.id;
            chil.onclick    = function()
            {
                _root.onchange(this);   
            };
            this.cboxs[count-1].childs[this.cboxs[count-1].childs.length]=chil;
            this.colnow.appendChild(chil);
        }
    };
    this.get=function()
    {
        var obj =new Object;
        obj.id  =new Array;
        obj.name=new Array;
        var c   = 0;
        for(i in this.cboxs)
        {
            var box     = this.cboxs[i];
            if(box.checked==true)
            {
                obj.id[c]   = box.id;
                obj.name[c] = box.innerHTML;
                c++;
            }
            for(j in box.childs)
            {
                if(box.childs[j].checked==true)
                {
                    obj.id[c]   = box.childs[j].id;
                    obj.name[c] = box.childs[j].innerHTML;
                    c++;
                }
            }
        }
      return obj;  
    };
    this.change    = function(obj,ch)
    {
       if(ch==true)
       {
            obj.checked=true;
            addClass(obj,'checked');
       }else
       {            
            obj.checked=false;
            removeClass(obj,'checked');
       }
    };
    this.onchange  = function(obj)
    {
        if(obj.checked==true)
        {
            obj.checked=false;
        }else
        {
            obj.checked=true;
        }
        this.change(obj,obj.checked);
        if(obj.g==true)
        {
            for(i in obj.childs)
            {
                this.change(obj.childs[i],obj.checked);
            }
        }
    }
}

function TScroll()
{
    this.init = function(arg)
    {
        var _root=this;
        this.arg=arg;
        if(!arg.s)
        {
            arg.s = 25;
        }        
        this.divroot    = document.getElementById(arg.idr);
        this.divtext    = document.getElementById(arg.idt);
        this.divscr     = document.createElement('div');
        this.divtop     = document.createElement('div');
        this.divbot     = document.createElement('div');
        this.divline    = document.createElement('div');
        this.divpin     = document.createElement('div');
        this.divscr.className='tscrolldscr';
        this.divtext.className='tscroll';
        this.divtop.className='tscrolltop';
        this.divbot.className='tscrollbot';
        this.divline.className='tscrollline';
        this.divpin.className='tscrollpin';
        this.divpin.style.marginTop = 20+'px';
        this.divscr.style.height=arg.h+'px';  
        this.divline.style.height=arg.h+'px';      
        this.divscr.style.marginLeft=(arg.w)+'px';
        this.divbot.style.marginTop=(arg.h-20)+'px';
        this.divroot.style.width=(arg.w-30)+'px';
        this.divroot.style.height=(arg.h)+'px';
        this.divscr.appendChild(this.divline);
        this.divscr.appendChild(this.divtop);
        this.divscr.appendChild(this.divbot);
        this.divscr.appendChild(this.divpin);   
        if(this.scrollh()<=0)return;     
        
        this.divroot.insertBefore(this.divscr,this.divroot.firstChild);
        this.divtop.onmouseover=function()
        {
            clearInterval(_root.tt);
            _root.tt=setInterval(function(){ _root.goscroll(-1)},arg.s);
        };
        this.divbot.onmouseover=function()
        {
            clearInterval(_root.tt);
            _root.tt=setInterval(function(){ _root.goscroll(1)},arg.s);
        };
        this.divtop.onclick=function()
        {
            clearInterval(_root.tt);
            _root.tt=setInterval(function(){ _root.goscroll(-3)},arg.s);
        };
        this.divbot.onclick=function()
        {
            clearInterval(_root.tt);
            _root.tt=setInterval(function(){ _root.goscroll(3)},arg.s);
        };
        this.divtop.onmouseout=this.divbot.onmouseout=function()
        {
           clearInterval(_root.tt);  
        };  
        this.divpin.onmousedown = function(e)
        {
            e = (e)? e : event;
            this.oldY   = e.clientY;   
            this.oldM   = parseInt(this.style.marginTop.replace('px',''));  
        };  
        this.divpin.onselectstart=function(){return false};
        document.onmousemove=function(e)
        {
            if(!_root.divpin.oldY)return;
            e = (e)? e : event;
            var mtp=e.clientY - _root.divpin.oldY + _root.divpin.oldM;
            if(mtp<20)mtp=20;
            if(mtp>_root.arg.h-40)mtp=_root.arg.h-40;
            _root.divpin.style.marginTop = mtp+'px';            
            _root.divtext.scrollTop=(mtp-20)/(_root.arg.h-60)*_root.scrollh();
        };
        document.onmouseup=function(e)
        {
            _root.divpin.oldY   = false;
        };
    };
    this.scrollh = function()
    {
        return this.divtext.scrollHeight-this.arg.h;
    };
    this.goscroll=function(arg)
    {
        this.divtext.scrollTop+=arg;            
        this.goPin();
    };
    this.goPin=function()
    {
        mgt=((this.divtext.scrollTop)/this.scrollh())*(this.arg.h-60);
        this.divpin.style.marginTop=(mgt +20)+'px';
    }
}

TrselBox={
    list : new Array,
    show : function(id)
    {        
        var _root   = this;
        var obj     = document.getElementById(id);
        this.list[id]= id;
        obj.onmouseout=function()
        {            
            this.tt=setTimeout(function(){_root.hide(id)},800);  
        };
        obj.onmouseover=function()
        {
            clearTimeout(this.tt);
        };
        if(obj.style.visibility!='')
        {
            for(j in this.list)
            {
                _root.hide(this.list[j]);
            }
            obj.style.visibility='';
            obj.style.height    = 0;
            obj.style.h    = 0;
            obj.td=setInterval(function(){obj.style.h+=15;if(obj.style.h>=obj.scrollHeight-10){clearInterval(obj.td)};obj.style.height=obj.style.h+'px'},25);
        }else
        {
            _root.hide(id);
        }  
    },
    hide : function(id)
    {
        var obj=document.getElementById(id);
        obj.style.visibility='hidden';
        clearInterval(obj.td);   
    }
};
function playvideo(id)
{
    div=document.getElementById('video_'+id);
    dsv=document.getElementById('vc_'+id);
    dcl=document.createElement('a');
    dmk=document.createElement('div');
    div.className='popupvideo fixed';
    dcl.className='pclose';
    div.style.display='';
    dmk.className='dmask';    
    dcl.onclick=function()
    {
        div.style.display='none';  
        div.removeChild(dmk);
        div.removeChild(dcl);
    };
    div.insertBefore(dmk,div.firstChild);
    dsv.insertBefore(dcl,dsv.firstChild);    
    dsv.style.top=((getSizePage().h-50)/2-420/2)+'px';    
}